package enumTest;

/**
 * @author Ajie
 * @date 3/25/22
 * @function 通过 oridin 拿到 name.
 * 结论：遍历 enum values. 通过 index 拿到 name.
 */
public class Enum_DataGetName {
    public static void main(String[] args) {

        float[] data = new float[5];
        data[1] = 2;
        System.out.println(FacePassSkinColorType.getNameFromOridinal((int)data[1]));
    }


    public static enum FacePassSkinColorType {
        YELLOW,
        WHITE,
        BLACK,
        BROWN,
        INVALID;

        private FacePassSkinColorType() {
        }
        public static String getNameFromOridinal(int i){
            FacePassSkinColorType[] values = FacePassSkinColorType.values();
            if (i<0 || i>= values.length)return null;
            return values[i].name();
        }

    }

    public static enum FacePassGlassesType {
        NO_GLASSES,
        GLASSES_WITH_DARK_FRAME,
        GLASSES_OTHERS,
        UNKNOWN,
        INVALID;

        private FacePassGlassesType() {
        }
        public static String getNameFromOridinal(int i){
            FacePassGlassesType[] values = FacePassGlassesType.values();
            if (i<0 || i>= values.length)return null;
            return values[i].name();
        }

    }

    public static enum FacePassRespiratorType {
        COVER_MOUTH_NOSE,
        COVER_MOUTH,
        NO_RESPIRATOR,
        UNKNOWN,
        INVALID;

        private FacePassRespiratorType() {
        }
        public static String getNameFromOridinal(int i){
            FacePassRespiratorType[] values = FacePassRespiratorType.values();
            if (i<0 || i>= values.length)return null;
            return values[i].name();
        }

    }

    public static enum FacePassHatType {
        NO_HAT,
        SAFETY_HELMET,
        OTHERS,
        UNKNOWN,
        INVALID;

        private FacePassHatType() {
        }
        public static String getNameFromOridinal(int i){
            FacePassHatType[] values = FacePassHatType.values();
            if (i<0 || i>= values.length)return null;
            return values[i].name();
        }

    }

    public static enum FacePassBeardType {
        NO_BEARD,
        MOUSTACHE,
        WHISKER,
        UNKNOWN,
        INVALID;

        private FacePassBeardType() {
        }
        public static String getNameFromOridinal(int i){
            FacePassBeardType[] values = FacePassBeardType.values();
            if (i<0 || i>= values.length)return null;
            return values[i].name();
        }

    }

    public static enum FacePassHairType {
        BALD,
        LITTLE_HAIR,
        SHORT_HAIR,
        LONG_HAIR,
        UNKNOWN,
        INVALID;

        private FacePassHairType() {
        }
        public static String getNameFromOridinal(int i){
            FacePassHairType[] values = FacePassHairType.values();
            if (i<0 || i>= values.length)return null;
            return values[i].name();
        }

    }
}
